<!DOCTYPE html>
<html lang="zh-CN">
<head hexo-theme='https://github.com/volantis-x/hexo-theme-volantis/tree/4.1.5'>
  <meta charset="utf-8">
  <!-- SEO相关 -->
  
    
  
  <!-- 渲染优化 -->
  <meta http-equiv='x-dns-prefetch-control' content='on' />
  <link rel='dns-prefetch' href='https://cdn.jsdelivr.net'>
  <link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin>
  <meta name="renderer" content="webkit">
  <meta name="force-rendering" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <meta name="HandheldFriendly" content="True" >
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

  <!-- 页面元数据 -->
  
  <title>Linux - Learn - Schenk - Blog</title>
  
    <meta name="keywords" content="linux">
  

  
    <meta name="description" content="Linux学习记录">
  

  <!-- feed -->
  

  <!-- import meta -->
  

  <!-- link -->
  
    <link rel="shortcut icon" type='image/x-icon' href="https://cdn.jsdelivr.net/gh/Schenk75/Source/logos/steroids.svg">
  

  <!-- import link -->
  

  
    
<link rel="stylesheet" href="/css/first.css">

  

  
  <link rel="stylesheet" href="/css/style.css" media="print" onload="this.media='all';this.onload=null">
  <noscript><link rel="stylesheet" href="/css/style.css"></noscript>
  

  <script id="loadcss"></script>

</head>

<body>
  

<header id="l_header" class="l_header auto shadow blur floatable show" style='opacity: 0' >
  <div class='container'>
  <div id='wrapper'>
    <div class='nav-sub'>
      <p class="title"></p>
      <ul class='switcher nav-list-h m-phone' id="pjax-header-nav-list">
        <li><a id="s-comment" class="fas fa-comments fa-fw" target="_self" href='javascript:void(0)'></a></li>
        
          <li><a id="s-toc" class="s-toc fas fa-list fa-fw" target="_self" href='javascript:void(0)'></a></li>
        
      </ul>
    </div>
		<div class="nav-main">
      
        
        <a class="title flat-box" target="_self" href='/'>
          
            <img no-lazy class='logo' src='https://cdn.jsdelivr.net/gh/Schenk75/Source@latest/logos/taiga.svg'/>
          
          
          
        </a>
      

			<div class='menu navigation'>
				<ul class='nav-list-h m-pc'>
          
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/
                  
                  
                  
                    id="home"
                  >
                  <i class='fab fa-stack-overflow fa-fw'></i>主页
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/categories/
                  
                  
                  
                    id="categories"
                  >
                  <i class='fas fa-folder-open fa-fw'></i>分类
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/tags/
                  
                  
                  
                    id="tags"
                  >
                  <i class='fas fa-tags fa-fw'></i>标签
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/archives/
                  
                  
                  
                    id="archives"
                  >
                  <i class='fas fa-archive fa-fw'></i>归档
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/friends/
                  
                  
                  
                    id="friends"
                  >
                  <i class='fas fa-link fa-fw'></i>友链
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/about/
                  
                  
                  
                    id="about"
                  >
                  <i class='fas fa-info-circle fa-fw'></i>关于
                </a>
                
              </li>
            
          
          
				</ul>
			</div>

      <div class="m_search">
        <form name="searchform" class="form u-search-form">
          <i class="icon fas fa-search fa-fw"></i>
          <input type="text" class="input u-search-input" placeholder="Search..." />
        </form>
      </div>

			<ul class='switcher nav-list-h m-phone'>
				
					<li><a class="s-search fas fa-search fa-fw" target="_self" href='javascript:void(0)'></a></li>
				
				<li>
          <a class="s-menu fas fa-bars fa-fw" target="_self" href='javascript:void(0)'></a>
          <ul class="menu-phone list-v navigation white-box">
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/
                  
                  
                  
                    id="home"
                  >
                  <i class='fab fa-stack-overflow fa-fw'></i>主页
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/categories/
                  
                  
                  
                    id="categories"
                  >
                  <i class='fas fa-folder-open fa-fw'></i>分类
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/tags/
                  
                  
                  
                    id="tags"
                  >
                  <i class='fas fa-tags fa-fw'></i>标签
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/archives/
                  
                  
                  
                    id="archives"
                  >
                  <i class='fas fa-archive fa-fw'></i>归档
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/friends/
                  
                  
                  
                    id="friends"
                  >
                  <i class='fas fa-link fa-fw'></i>友链
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/about/
                  
                  
                  
                    id="about"
                  >
                  <i class='fas fa-info-circle fa-fw'></i>关于
                </a>
                
              </li>
            
          
            
          </ul>
        </li>
			</ul>
		</div>
	</div>
  </div>
</header>

  <div id="l_body">
    <div id="l_cover">
  
    
        <div id="full" class='cover-wrapper post dock' style="display: none;">
          
            <div class='cover-bg lazyload placeholder' data-bg="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/common/interstellar.jpg"></div>
          
          <div class='cover-body'>
  <div class='top'>
    
    
      <p class="title">Schenk - Blog</p>
    
    
      <p class="subtitle">SJTUer | Cuber</p>
    
  </div>
  <div class='bottom'>
    <div class='menu navigation'>
      <div class='list-h'>
        
          
            <a href="/categories/"
              
              
              id="categories">
              <i class='fas fa-folder-open fa-fw'></i><p>分类</p>
            </a>
          
            <a href="/tags/"
              
              
              id="tags">
              <i class='fas fa-tags fa-fw'></i><p>标签</p>
            </a>
          
            <a href="/archives/"
              
              
              id="archives">
              <i class='fas fa-archive fa-fw'></i><p>归档</p>
            </a>
          
            <a href="/friends/"
              
              
              id="friends">
              <i class='fas fa-link fa-fw'></i><p>友链</p>
            </a>
          
            <a href="/about/"
              
              
              id="about">
              <i class='fas fa-info-circle fa-fw'></i><p>关于</p>
            </a>
          
        
      </div>
    </div>
  </div>
</div>

          <div id="scroll-down" style="display: none;"><i class="fa fa-chevron-down scroll-down-effects"></i></div>
        </div>
    
  
  </div>

    <div id='safearea'>
      <div class='body-wrapper' id="pjax-container">
        

<div class='l_main'>
  <article class="article post white-box reveal md shadow floatable article-type-post" id="post" itemscope itemprop="blogPost">
  


  
  <div class="article-meta" id="top">
    
    
    
      <h1 class="title">
        Linux - Learn
      </h1>
      <div class='new-meta-box'>
        
          
            
<div class='new-meta-item author'>
  <a class='author' href="/" rel="nofollow">
    <img no-lazy src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/common/avatar.jpg">
    <p>Schenk</p>
  </a>
</div>

          
        
          
            
  <div class='new-meta-item category'>
    <a class='notlink'>
      <i class="fas fa-folder-open fa-fw" aria-hidden="true"></i>
      <a class="category-link" href="/categories/Linux/">Linux</a><span class="sep"></span><a class="category-link" href="/categories/Notes/">Notes</a>
    </a>
  </div>


          
        
          
            <div class="new-meta-item date" itemprop="dateUpdated" datetime="2022-04-28T15:30:40+08:00">
  <a class='notlink'>
    <i class="fas fa-edit fa-fw" aria-hidden="true"></i>
    <p>更新于：2022年4月28日</p>
  </a>
</div>

          
        
          
            
  <div class="new-meta-item wordcount">
    <a class='notlink'>
      <i class="fas fa-keyboard fa-fw" aria-hidden="true"></i>
      <p>字数：2.6k字</p>
    </a>
  </div>
  <div class="new-meta-item readtime">
    <a class='notlink'>
      <i class="fas fa-hourglass-half fa-fw" aria-hidden="true"></i>
      <p>时长：10分钟</p>
    </a>
  </div>


          
        
          
            
  <div class="new-meta-item browse leancloud">
    <a class='notlink'>
      
      <div id="lc-pv" data-title="Linux - Learn" data-path="/2020/11/04/learning-notes/Linux%E5%AD%A6%E4%B9%A0/">
        <i class="fas fa-eye fa-fw" aria-hidden="true"></i>
        <span id='number'><i class="fas fa-circle-notch fa-spin fa-fw" aria-hidden="true"></i></span>
        次浏览
      </div>
    </a>
  </div>


          
        
      </div>
    
  </div>


  
  <h2 id="了解系统信息">了解系统信息</h2>
<h3 id="硬盘大小">硬盘大小</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">fdisk -l</span><br><span class="line">&#x2F;dev&#x2F;sda 操作系统中第一块硬盘的名称以及所在路径</span><br><span class="line">Linux操作系统一切皆文件 （文件名） sd (硬盘类型) a（第一块）</span><br></pre></td></tr></table></figure>
<h3 id="内存大小">内存大小</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cat &#x2F;proc&#x2F;meminfo</span><br></pre></td></tr></table></figure>
<h3 id="cpu大小">cpu大小</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cat &#x2F;proc&#x2F;cpuinfo</span><br></pre></td></tr></table></figure>
<h3 id="收集系统信息">收集系统信息</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">uname -a</span><br></pre></td></tr></table></figure>
<h2 id="Linux文件系统">Linux文件系统</h2>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;bin    普通用户和管理员都可以执行的命令</span><br><span class="line">&#x2F;sbin   只有管理员才能执行的命令 eg.关机重启</span><br><span class="line">&#x2F;boot   引导 主引导目录 独立的分区 启动菜单 内核</span><br><span class="line">&#x2F;dev    device 设备文件存放目录</span><br><span class="line">&#x2F;etc    配置文件存放目录</span><br><span class="line">&#x2F;home   普通用户的家目录</span><br><span class="line">&#x2F;root   管理员的家</span><br><span class="line">&#x2F;media  光驱的挂载目录</span><br><span class="line">&#x2F;mnt    临时设备的挂载目录</span><br><span class="line">&#x2F;proc   里面的数据都在内存中，进程的所在目录</span><br><span class="line">&#x2F;tmp    临时文件存放目录</span><br><span class="line">&#x2F;usr    第三方软件的安装目录</span><br><span class="line">&#x2F;var    常变文件存放目录 eg.日志文件、邮件文件</span><br></pre></td></tr></table></figure>
<h3 id="挂载光驱">挂载光驱</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">弹出光驱：umount &#x2F;dev&#x2F;cdrom</span><br><span class="line">挂载光驱：mount &#x2F;dev&#x2F;cdrom &#x2F;media</span><br></pre></td></tr></table></figure>
<h2 id="Linux文件类型的显示颜色">Linux文件类型的显示颜色</h2>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">蓝色 目录</span><br><span class="line">黑色 普通文件</span><br><span class="line">浅蓝色 符号链接（快捷方式）</span><br><span class="line">黑底黄字 设备文件 硬盘 sda</span><br><span class="line">红色 压缩包</span><br><span class="line">绿色 带有执行权限的文件</span><br><span class="line">紫色 图片 模块文件</span><br></pre></td></tr></table></figure>
<h2 id="压缩和解压缩">压缩和解压缩</h2>
<h3 id="文件压缩和解压缩">文件压缩和解压缩</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">gzip bigfile</span><br><span class="line">gunzip bigfile.gz</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">bzip2 bigfile</span><br><span class="line">bunzip2 bigfile.bz2</span><br></pre></td></tr></table></figure>
<h3 id="目录-文件夹-打包压缩">目录(文件夹)打包压缩</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">tar -zcf &#x2F;tmp&#x2F;allfile.tar.gz &#x2F;tmp&#x2F;allfile</span><br><span class="line">tar -jcf &#x2F;tmp&#x2F;allfile.tar.bz2 &#x2F;tmp&#x2F;allfile</span><br></pre></td></tr></table></figure>
<h3 id="目录-文件夹-解压缩并解包">目录(文件夹)解压缩并解包</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">tar -zxf &#x2F;tmp&#x2F;allfile.tar.gz -C &#x2F;tmp</span><br><span class="line">tar -jxf &#x2F;tmp&#x2F;allfile.tar.bz2 -C &#x2F;tmp</span><br><span class="line">-C 指定解包位置</span><br></pre></td></tr></table></figure>
<h2 id="vim">vim</h2>
<h3 id="模式切换">模式切换</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">命令模式 -&gt; 输入模式：i</span><br><span class="line">输入模式 -&gt; 命令模式：Esc</span><br><span class="line">命令模式 -&gt; 末行模式：:</span><br></pre></td></tr></table></figure>
<h3 id="末行模式命令">末行模式命令</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">:wq   保存并退出</span><br><span class="line">:q!    不保存退出</span><br><span class="line">:set nu   显示行号</span><br><span class="line">:% s&#x2F;old&#x2F;new&#x2F;g   每一行中的old替换成new</span><br><span class="line">:50,56 d     删除50-56行的数据</span><br></pre></td></tr></table></figure>
<h3 id="命令模式命令">命令模式命令</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">0       光标移动到当前行首</span><br><span class="line">$       光标移动到当前行末</span><br><span class="line">yy      复制当前行</span><br><span class="line">2yy     复制当前行以及后一行，其他数字以此类推</span><br><span class="line">p       粘贴到当前行下一行</span><br><span class="line">dd      删除当前行</span><br><span class="line">gg      回到第一行</span><br><span class="line">G       回到最后一行</span><br></pre></td></tr></table></figure>
<h2 id="Linux软件安装——封装后的软件包">Linux软件安装——封装后的软件包</h2>
<h3 id="后缀名">后缀名</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">rpm     red hat系统</span><br><span class="line">deb     debian系统</span><br><span class="line">源码包  不考虑系统版本</span><br></pre></td></tr></table></figure>
<h3 id="有关软件包安装的命令">有关软件包安装的命令</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">rpm -qa             列出所有已经安装的rpm包</span><br><span class="line">查询特定的rpm包使用管道符：rpm -qa | grep &quot;tree&quot;</span><br><span class="line">rpm -qpi 软件名     确认该软件的作用</span><br><span class="line">rpm -qpl 软件名     确认该软件的安装路径(无法修改)</span><br><span class="line">rpm -ivh 软件名     安装软件</span><br><span class="line">rpm -e 软件名       软件卸载</span><br></pre></td></tr></table></figure>
<h2 id="Linux软件安装——yum">Linux软件安装——yum</h2>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">yum install 软件名</span><br><span class="line">yum remove 软件名</span><br></pre></td></tr></table></figure>
<h2 id="用户和组">用户和组</h2>
<h3 id="三个重要文件">三个重要文件</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;etc&#x2F;passwd     保存操作系统中所有的用户信息</span><br><span class="line">root : x : 0 : 0 : root : &#x2F;root : &#x2F;bin&#x2F;bash</span><br><span class="line">每一条目共7个字段，用冒号隔开</span><br><span class="line">字段1：用户名</span><br><span class="line">字段2：密码占位符</span><br><span class="line">字段3：用户的UID</span><br><span class="line">    0 表示超级用户</span><br><span class="line">    500-60000 普通用户</span><br><span class="line">    1-499 程序用户</span><br><span class="line">字段4：基本组的GID，先有组才有用户</span><br><span class="line">字段5：用户信息记录字段</span><br><span class="line">字段6：用户的家目录</span><br><span class="line">字段7：用户登录系统后使用的命令解释器</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;etc&#x2F;shadow     保存了用户密码信息</span><br><span class="line">root : $6$ME9wjPHAid5ds$PO&#x2F;GlBVEt1 : 18325 : 0 : 99999 : 7 :::</span><br><span class="line">字段1：用户名</span><br><span class="line">*字段2：用户的密码加盐并通过散列算法后的字符串（sha）</span><br><span class="line">字段3：距离1970&#x2F;1&#x2F;1密码最近一次修改的时间</span><br><span class="line">字段4：密码的最短有效期</span><br><span class="line">*字段5：密码的最长有效期（建议时间 90）</span><br><span class="line">字段6：密码过期前7天警告</span><br><span class="line">字段7：密码的不活跃期</span><br><span class="line">字段8：用户的失效时间</span><br></pre></td></tr></table></figure>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;etc&#x2F;group      记录了系统中所有组的信息</span><br></pre></td></tr></table></figure>
<h3 id="建立和调整用户属性">建立和调整用户属性</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">1、建立一个名为class1的组ID为1000，class2的组ID为2000</span><br><span class="line">建立：</span><br><span class="line">groupadd class1</span><br><span class="line">groupadd -g 2000 class2</span><br><span class="line">修改gid：</span><br><span class="line">groupmod -g 1000 class1</span><br><span class="line">查看：</span><br><span class="line">vim &#x2F;etc&#x2F;group</span><br><span class="line"></span><br><span class="line">2、建立tom用户要求其基本组是class1,附加组为class2，tom用户的UID为600</span><br><span class="line">建立：</span><br><span class="line">useradd -g class1 -G class2 -u 600 tom</span><br><span class="line">修改：</span><br><span class="line">usermod</span><br><span class="line">查看：</span><br><span class="line">id tom</span><br><span class="line"></span><br><span class="line">3、建立一个程序用户UID为250,用户名为testuser，没有家目录（程序用户没有登录系统权限）</span><br><span class="line">useradd -u 250 -M -s &#x2F;sbin&#x2F;nologin testuser</span><br><span class="line">-M：没有家目录</span><br><span class="line">-s &#x2F;sbin&#x2F;nologin：不能登录</span><br><span class="line"></span><br><span class="line">4、为tom用户设定密码为123，并设定密码最长有效期为90天，将用户密码进行锁定使其无法登录</span><br><span class="line">passwd tom        设定密码</span><br><span class="line">chage -M 90 tom   设定密码最长有效期</span><br><span class="line">或者修改配置文件&#x2F;etc&#x2F;login.defs</span><br><span class="line">passwd -l tom     锁定</span><br><span class="line">passwd -u tom     解锁</span><br><span class="line">查看：</span><br><span class="line">passwd -S tom</span><br><span class="line">vim &#x2F;etc&#x2F;shadow</span><br><span class="line"></span><br><span class="line">5、删除tom用户和testuser用户，删除class1组和class2组</span><br><span class="line">userdel -r tom     （-r  连同用户的家目录一起删除）</span><br><span class="line">userdel -r testuser</span><br><span class="line">groupdel class1</span><br><span class="line">groupdel class1</span><br></pre></td></tr></table></figure>
<h2 id="文件目录权限">文件目录权限</h2>
<h3 id="列出文件信息">列出文件信息</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">ls -a       列出所有文件，包括隐藏文件</span><br><span class="line">ls -l(ll)   列出文件详细信息</span><br><span class="line">文件：-rw-rw-r--.(权限) 1(链接数) centos(所属用户) centos(所属组)   12(文件大小，字节) Sep 12 10:07(最后修改时间) test.txt</span><br><span class="line">目录：drwxrwxr-x.(权限) 2(子目录数) centos(所属用户) centos(所属组)    6 Sep 12 10:06(最后修改时间) testdir</span><br><span class="line">ls -ld      列出某一目录的详细信息</span><br><span class="line">ls -h       用人能看懂的方式显示文件大小</span><br></pre></td></tr></table></figure>
<h3 id="权限详细">权限详细</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">- rw- rw- r--.</span><br><span class="line">d rwx rwx r-x.</span><br><span class="line">共4个字段</span><br><span class="line">字段1：文件类型</span><br><span class="line">    -普通文件</span><br><span class="line">    d目录文件</span><br><span class="line">    l符号链接文件</span><br><span class="line">    b块设备</span><br><span class="line">字段2：文件所属者的权限</span><br><span class="line">            r               w           x</span><br><span class="line">    文件    读取            写入        可执行</span><br><span class="line">    目录    查看目录文件    增删文件    进入目录</span><br><span class="line">字段3：文件所属组的权限</span><br><span class="line">字段4：其他用户的权限</span><br></pre></td></tr></table></figure>
<h3 id="赋权限">赋权限</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">方法1：chmod 对象 算术运算符 权限 文件</span><br><span class="line">    对象：u-所属者 g-所属组 o-其他用户 a-所有用户</span><br><span class="line">    算术运算符：- + &#x3D;</span><br><span class="line">    权限：r w x</span><br><span class="line">方法2：chmod 777 文件</span><br></pre></td></tr></table></figure>
<h3 id="改变文件的所属者和所属组">改变文件的所属者和所属组</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">chown 用户 文件</span><br><span class="line">chgrp 组 文件</span><br></pre></td></tr></table></figure>
<h3 id="粘滞位-sgid-suid权限">粘滞位 sgid suid权限</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">粘滞位针对目录赋权，目录中创建的文件只有建立者可以删除</span><br><span class="line">    chmod o+t 文件</span><br><span class="line">    chmod o-t 文件</span><br><span class="line">sgid 针对目录建立的权限，在该目录中建立的文件所属组继承父目录的所属组</span><br><span class="line">    chmod g+s 文件</span><br><span class="line">    chmod g-s 文件</span><br><span class="line">suid 对可执行文件建立。谁运行该文件，就具有该文件所属者的权限</span><br><span class="line">    chmod u+s 文件</span><br><span class="line">    chmod u-s 文件</span><br><span class="line">    eg. chmod u+s &#x2F;usr&#x2F;bin&#x2F;vim</span><br></pre></td></tr></table></figure>
<h3 id="查找有异常权限的文件">查找有异常权限的文件</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">查找有suid权限的可执行文件</span><br><span class="line">find &#x2F;usr&#x2F;bin -perm 4755</span><br><span class="line">其中权限的第一个4表示suid权限，如果是2则表示sgid权限，如果是1则表示粘滞位</span><br><span class="line">权限的多一位也可以用于赋权限</span><br></pre></td></tr></table></figure>
<h3 id="不再允许添加新用户">不再允许添加新用户</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">新建用户时会更改的文件</span><br><span class="line">    &#x2F;etc&#x2F;group</span><br><span class="line">    &#x2F;etc&#x2F;passwd</span><br><span class="line">    &#x2F;etc&#x2F;shadow</span><br><span class="line">    home&#x2F;xxxx</span><br><span class="line">锁定文件从而不能添加新用户</span><br><span class="line">    chattr +i &#x2F;etc&#x2F;passwd &#x2F;etc&#x2F;shadow</span><br><span class="line">查看文件是否被锁定</span><br><span class="line">    lsattr &#x2F;etc&#x2F;passwd</span><br></pre></td></tr></table></figure>
<h3 id="umask">umask</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">一般目录的最高权限是777</span><br><span class="line">一般文件的最高权限是666</span><br><span class="line">用户创建的文件通过umask来确定其权限</span><br><span class="line">root的umask是0022(第一位是特殊权限)</span><br><span class="line">普通用户并且uid&#x3D;sid的umask是0002</span><br><span class="line"></span><br><span class="line">umask的设置在&#x2F;etc&#x2F;profile和&#x2F;etc&#x2F;bashrc两个文件中</span><br></pre></td></tr></table></figure>
<h2 id="网络地址配置">网络地址配置</h2>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">1. 确认网卡信息：ip addr &#x2F; ifconfig</span><br><span class="line">2. 关闭NetworkManager服务：systemctl stop NetworkManager</span><br><span class="line">3. 网卡启用桥接模式，并配置网络地址：</span><br><span class="line">    ip addr add IP&#x2F;掩码长度 dev ens33</span><br><span class="line">4. 设置网关：</span><br><span class="line">    ip route add default via IP dev ens33</span><br><span class="line">5. 配置DNS：</span><br><span class="line">    vim &#x2F;etc&#x2F;resolv.conf</span><br><span class="line">    nameserver 202.120.2.101</span><br><span class="line">6. 关闭防火墙：</span><br><span class="line">    systemctl stop firewalld.service</span><br></pre></td></tr></table></figure>
<h2 id="日志文件">日志文件</h2>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">位置：&#x2F;var&#x2F;log</span><br><span class="line">日志记录的配置文件：&#x2F;etc&#x2F;rsyslog.conf</span><br><span class="line">    其中配置方式为 日志类型.日志级别 ，如authpriv.*表示记录所有级别的登录日志</span><br><span class="line">日志分类：</span><br><span class="line">    系统日志    &#x2F;var&#x2F;log&#x2F;messages</span><br><span class="line">    登录日志    &#x2F;var&#x2F;log&#x2F;secure</span><br><span class="line">    程序日志</span><br><span class="line">日志记录的日志级别：</span><br><span class="line">debug,  info,  notice, warning(warn), err(error), crit, alert, emerg(panic)</span><br><span class="line">最不严重  -&gt; 最严重</span><br><span class="line"></span><br><span class="line">配置日志备份服务器：https:&#x2F;&#x2F;blog.csdn.net&#x2F;weixin_43252204&#x2F;article&#x2F;details&#x2F;105518163</span><br></pre></td></tr></table></figure>
<h2 id="WEB服务-apache">WEB服务-apache</h2>
<h3 id="开启并使用apache">开启并使用apache</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">1. 启动服务</span><br><span class="line">    service httpd start</span><br><span class="line">2. 验证服务是否开启</span><br><span class="line">    ss -antpl | grep 80</span><br><span class="line">3. 主页建立</span><br><span class="line">    vim &#x2F;var&#x2F;www&#x2F;html&#x2F;index.html</span><br></pre></td></tr></table></figure>
<h3 id="httpd配置文件">httpd配置文件</h3>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">位置：&#x2F;etc&#x2F;httpd&#x2F;conf&#x2F;httpd.conf</span><br><span class="line">默认会开启共享目录功能，这样会导致别人可以远程下载&#x2F;var&#x2F;www&#x2F;html中的内容，建议将其关闭：</span><br><span class="line">    Options Indexes FollowSymLinks改为Options FollowSymLinks</span><br><span class="line">限制访问，将Require all granted修改为以下语句：</span><br><span class="line">    &lt;RequireAll&gt;</span><br><span class="line">    Require all granted</span><br><span class="line">    Require not ip 192.168.1.10 192.168.2.0&#x2F;24</span><br><span class="line">        &#x2F;&#x2F;拒绝192.168.1.10和192.168.2.0网段客户机访问</span><br><span class="line">    &lt;&#x2F;RequireAll&gt;</span><br><span class="line">用户授权限制，只有通过指定的用户名密码才能访问网页：</span><br><span class="line">    设置用户名密码：htpasswd -c &#x2F;etc&#x2F;httpd&#x2F;conf&#x2F;httpuser test   (-c表示新建文件)</span><br><span class="line">    设置该文件只有apache用户可读：</span><br><span class="line">        chown apache httpuser</span><br><span class="line">        chmod 400 httpuser</span><br><span class="line">    修改配置文件：</span><br><span class="line">        Authtype basic</span><br><span class="line">        Authname &quot;Input username and password&quot; &#x2F;&#x2F; 提示信息</span><br><span class="line">        Authuserfile &#x2F;etc&#x2F;httpd&#x2F;conf&#x2F;httpuser</span><br><span class="line">        Require valid-user</span><br></pre></td></tr></table></figure>
<h2 id="lamp平台搭建">lamp平台搭建</h2>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">1. 安装apache</span><br><span class="line">2. 安装mysql</span><br><span class="line">    yum install mysql-server    &#x2F;&#x2F; 安装</span><br><span class="line">    service mysqld start        &#x2F;&#x2F; 启动</span><br><span class="line">    mysqladmin -u root -p password &quot;123.sck&quot;     &#x2F;&#x2F; 设置root密码</span><br><span class="line">    mysql -u root -p        &#x2F;&#x2F; 登录数据库</span><br><span class="line">3. 安装php</span><br><span class="line">    yum install php</span><br><span class="line">    yum install php-mysqlnd</span><br><span class="line">    yum install php-mbstring</span><br><span class="line">4. 配置php配置文件</span><br><span class="line">    vim &#x2F;etc&#x2F;php.ini</span><br><span class="line">    将short_open_tag从Off改为On</span><br><span class="line">5. 在&#x2F;var&#x2F;www&#x2F;html新建一个php文件</span><br></pre></td></tr></table></figure>
<h2 id="iptables防火墙">iptables防火墙</h2>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">四个表：</span><br><span class="line">    raw</span><br><span class="line">    mangle</span><br><span class="line">    nat     网络地址转换</span><br><span class="line">    filter  过滤</span><br></pre></td></tr></table></figure>
  
  
    
    <div class='footer'>
      
      
      
      
    </div>
  
  
    


  <div class='article-meta' id="bottom">
    <div class='new-meta-box'>
      
        
          <div class="new-meta-item date">
  <a class='notlink'>
    <i class="fas fa-calendar-alt fa-fw" aria-hidden="true"></i>
    <p>发布于：2020年11月4日</p>
  </a>
</div>

        
      
        
          
  
  <div class="new-meta-item meta-tags"><a class="tag" href="/tags/linux/" rel="nofollow"><i class="fas fa-hashtag fa-fw" aria-hidden="true"></i><p>linux</p></a></div>


        
      
    </div>
  </div>


  
  

  
    <div class="prev-next">
      
        <a class='prev' href='/2020/11/04/others/%E5%A4%8D%E4%B9%A0-SQ1%E5%A4%8D%E5%BD%A2/'>
          <p class='title'><i class="fas fa-chevron-left" aria-hidden="true"></i>复习 - SQ1复形</p>
          <p class='content'>Overview

CS Algs by Depth
Depth 1



Shape
Scramble
Solve





/
/



Depth 2



Shape
Scramble
...</p>
        </a>
      
      
        <a class='next' href='/2020/11/03/instruction/Hexo-Volantis%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2%E9%83%A8%E7%BD%B2/'>
          <p class='title'>Hexo+Volantis个人博客部署<i class="fas fa-chevron-right" aria-hidden="true"></i></p>
          <p class='content'>配置部署Hexo
配置流程


参考链接

安装npm
安装git
其中配置npm源

123456# 获取npm源npm get registry# 修改为淘宝源npm config set ...</p>
        </a>
      
    </div>
  
</article>


  

  






</div>
<aside class='l_side'>
  
  
    
    



  <section class="widget toc-wrapper shadow floatable desktop mobile" id="toc-div" >
    
  <header>
    
      <i class="fas fa-list fa-fw" aria-hidden="true"></i><span class='name'>本文目录</span>
    
  </header>


    <div class='content'>
        <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BA%86%E8%A7%A3%E7%B3%BB%E7%BB%9F%E4%BF%A1%E6%81%AF"><span class="toc-text">了解系统信息</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%A1%AC%E7%9B%98%E5%A4%A7%E5%B0%8F"><span class="toc-text">硬盘大小</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%86%85%E5%AD%98%E5%A4%A7%E5%B0%8F"><span class="toc-text">内存大小</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#cpu%E5%A4%A7%E5%B0%8F"><span class="toc-text">cpu大小</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%94%B6%E9%9B%86%E7%B3%BB%E7%BB%9F%E4%BF%A1%E6%81%AF"><span class="toc-text">收集系统信息</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Linux%E6%96%87%E4%BB%B6%E7%B3%BB%E7%BB%9F"><span class="toc-text">Linux文件系统</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8C%82%E8%BD%BD%E5%85%89%E9%A9%B1"><span class="toc-text">挂载光驱</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Linux%E6%96%87%E4%BB%B6%E7%B1%BB%E5%9E%8B%E7%9A%84%E6%98%BE%E7%A4%BA%E9%A2%9C%E8%89%B2"><span class="toc-text">Linux文件类型的显示颜色</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8E%8B%E7%BC%A9%E5%92%8C%E8%A7%A3%E5%8E%8B%E7%BC%A9"><span class="toc-text">压缩和解压缩</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E5%8E%8B%E7%BC%A9%E5%92%8C%E8%A7%A3%E5%8E%8B%E7%BC%A9"><span class="toc-text">文件压缩和解压缩</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E5%BD%95-%E6%96%87%E4%BB%B6%E5%A4%B9-%E6%89%93%E5%8C%85%E5%8E%8B%E7%BC%A9"><span class="toc-text">目录(文件夹)打包压缩</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%9B%AE%E5%BD%95-%E6%96%87%E4%BB%B6%E5%A4%B9-%E8%A7%A3%E5%8E%8B%E7%BC%A9%E5%B9%B6%E8%A7%A3%E5%8C%85"><span class="toc-text">目录(文件夹)解压缩并解包</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#vim"><span class="toc-text">vim</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%A8%A1%E5%BC%8F%E5%88%87%E6%8D%A2"><span class="toc-text">模式切换</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9C%AB%E8%A1%8C%E6%A8%A1%E5%BC%8F%E5%91%BD%E4%BB%A4"><span class="toc-text">末行模式命令</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%91%BD%E4%BB%A4%E6%A8%A1%E5%BC%8F%E5%91%BD%E4%BB%A4"><span class="toc-text">命令模式命令</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Linux%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E2%80%94%E2%80%94%E5%B0%81%E8%A3%85%E5%90%8E%E7%9A%84%E8%BD%AF%E4%BB%B6%E5%8C%85"><span class="toc-text">Linux软件安装——封装后的软件包</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%90%8E%E7%BC%80%E5%90%8D"><span class="toc-text">后缀名</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9C%89%E5%85%B3%E8%BD%AF%E4%BB%B6%E5%8C%85%E5%AE%89%E8%A3%85%E7%9A%84%E5%91%BD%E4%BB%A4"><span class="toc-text">有关软件包安装的命令</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#Linux%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E2%80%94%E2%80%94yum"><span class="toc-text">Linux软件安装——yum</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%94%A8%E6%88%B7%E5%92%8C%E7%BB%84"><span class="toc-text">用户和组</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%89%E4%B8%AA%E9%87%8D%E8%A6%81%E6%96%87%E4%BB%B6"><span class="toc-text">三个重要文件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BB%BA%E7%AB%8B%E5%92%8C%E8%B0%83%E6%95%B4%E7%94%A8%E6%88%B7%E5%B1%9E%E6%80%A7"><span class="toc-text">建立和调整用户属性</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E7%9B%AE%E5%BD%95%E6%9D%83%E9%99%90"><span class="toc-text">文件目录权限</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%97%E5%87%BA%E6%96%87%E4%BB%B6%E4%BF%A1%E6%81%AF"><span class="toc-text">列出文件信息</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9D%83%E9%99%90%E8%AF%A6%E7%BB%86"><span class="toc-text">权限详细</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%B5%8B%E6%9D%83%E9%99%90"><span class="toc-text">赋权限</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%94%B9%E5%8F%98%E6%96%87%E4%BB%B6%E7%9A%84%E6%89%80%E5%B1%9E%E8%80%85%E5%92%8C%E6%89%80%E5%B1%9E%E7%BB%84"><span class="toc-text">改变文件的所属者和所属组</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%B2%98%E6%BB%9E%E4%BD%8D-sgid-suid%E6%9D%83%E9%99%90"><span class="toc-text">粘滞位 sgid suid权限</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E6%89%BE%E6%9C%89%E5%BC%82%E5%B8%B8%E6%9D%83%E9%99%90%E7%9A%84%E6%96%87%E4%BB%B6"><span class="toc-text">查找有异常权限的文件</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%8D%E5%86%8D%E5%85%81%E8%AE%B8%E6%B7%BB%E5%8A%A0%E6%96%B0%E7%94%A8%E6%88%B7"><span class="toc-text">不再允许添加新用户</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#umask"><span class="toc-text">umask</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%BD%91%E7%BB%9C%E5%9C%B0%E5%9D%80%E9%85%8D%E7%BD%AE"><span class="toc-text">网络地址配置</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%97%A5%E5%BF%97%E6%96%87%E4%BB%B6"><span class="toc-text">日志文件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#WEB%E6%9C%8D%E5%8A%A1-apache"><span class="toc-text">WEB服务-apache</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BC%80%E5%90%AF%E5%B9%B6%E4%BD%BF%E7%94%A8apache"><span class="toc-text">开启并使用apache</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#httpd%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="toc-text">httpd配置文件</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#lamp%E5%B9%B3%E5%8F%B0%E6%90%AD%E5%BB%BA"><span class="toc-text">lamp平台搭建</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#iptables%E9%98%B2%E7%81%AB%E5%A2%99"><span class="toc-text">iptables防火墙</span></a></li></ol>
    </div>
  </section>


  


</aside>



        
        
          <!--此文件用来存放一些不方便取值的变量-->
<!--思路大概是将值藏到重加载的区域内-->

<script>
  window.pdata={}
  pdata.ispage=true;
  pdata.postTitle="Linux - Learn";
  pdata.commentPath="";
  pdata.commentPlaceholder="";

  var l_header=document.getElementById("l_header");
  
  l_header.classList.add("show");
  
</script>

        
      </div>
      
  
  <footer class="footer clearfix">
    <br><br>
    
      
        <div class='copyright'>
        <p><a target="_blank" rel="noopener" href="https://github.com/Schenk75/Schenk75.github.io">Copyright © 2020-2022 Schenk</a></p>

        </div>
      
    
  </footer>


      <a id="s-top" class="fas fa-arrow-up fa-fw" href='javascript:void(0)'></a>
    </div>
  </div>
  <div>
    <script>
window.volantis={};
window.volantis.loadcss=document.getElementById("loadcss");
/********************脚本懒加载函数********************************/
function loadScript(src, cb) {
var HEAD = document.getElementsByTagName('head')[0] || document.documentElement;
var script = document.createElement('script');
script.setAttribute('type','text/javascript');
if (cb) script.onload = cb;
script.setAttribute('src', src);
HEAD.appendChild(script);
}
//https://github.com/filamentgroup/loadCSS
var loadCSS = function( href, before, media, attributes ){
	var doc = window.document;
	var ss = doc.createElement( "link" );
	var ref;
	if( before ){
		ref = before;
	}
	else {
		var refs = ( doc.body || doc.getElementsByTagName( "head" )[ 0 ] ).childNodes;
		ref = refs[ refs.length - 1];
	}
	var sheets = doc.styleSheets;
	if( attributes ){
		for( var attributeName in attributes ){
			if( attributes.hasOwnProperty( attributeName ) ){
				ss.setAttribute( attributeName, attributes[attributeName] );
			}
		}
	}
	ss.rel = "stylesheet";
	ss.href = href;
	ss.media = "only x";
	function ready( cb ){
		if( doc.body ){
			return cb();
		}
		setTimeout(function(){
			ready( cb );
		});
	}
	ready( function(){
		ref.parentNode.insertBefore( ss, ( before ? ref : ref.nextSibling ) );
	});
	var onloadcssdefined = function( cb ){
		var resolvedHref = ss.href;
		var i = sheets.length;
		while( i-- ){
			if( sheets[ i ].href === resolvedHref ){
				return cb();
			}
		}
		setTimeout(function() {
			onloadcssdefined( cb );
		});
	};
	function loadCB(){
		if( ss.addEventListener ){
			ss.removeEventListener( "load", loadCB );
		}
		ss.media = media || "all";
	}
	if( ss.addEventListener ){
		ss.addEventListener( "load", loadCB);
	}
	ss.onloadcssdefined = onloadcssdefined;
	onloadcssdefined( loadCB );
	return ss;
};
</script>
<script>
  
  loadCSS("https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.14/css/all.min.css", window.volantis.loadcss);
  
  
  
  
</script>
<!-- required -->

<script src="https://cdn.jsdelivr.net/npm/jquery@3.5/dist/jquery.min.js"></script>

<script>
  function pjax_fancybox() {
    $(".md .gallery").find("img").each(function () { //渲染 fancybox
      var element = document.createElement("a"); // a 标签
      $(element).attr("class", "fancybox");
      $(element).attr("pjax-fancybox", "");  // 过滤 pjax
      $(element).attr("href", $(this).attr("src"));
      if ($(this).attr("data-original")) {
        $(element).attr("href", $(this).attr("data-original"));
      }
      $(element).attr("data-fancybox", "images");
      var caption = "";   // 描述信息
      if ($(this).attr('alt')) {  // 判断当前页面是否存在描述信息
        $(element).attr('data-caption', $(this).attr('alt'));
        caption = $(this).attr('alt');
      }
      var div = document.createElement("div");
      $(div).addClass("fancybox");
      $(this).wrap(div); // 最外层套 div ，其实主要作用还是 class 样式
      var span = document.createElement("span");
      $(span).addClass("image-caption");
      $(span).text(caption); // 加描述
      $(this).after(span);  // 再套一层描述
      $(this).wrap(element);  // 最后套 a 标签
    })
    $(".md .gallery").find("img").fancybox({
      selector: '[data-fancybox="images"]',
      hash: false,
      loop: false,
      closeClick: true,
      helpers: {
        overlay: {closeClick: true}
      },
      buttons: [
        "zoom",
        "close"
      ]
    });
  };
  function SCload_fancybox() {
    if ($(".md .gallery").find("img").length == 0) return;
    loadCSS("https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css", document.getElementById("loadcss"));
    setTimeout(function() {
      loadScript('https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js', pjax_fancybox)
    }, 1);
  };
  $(function () {
    SCload_fancybox();
  });
</script>


<!-- internal -->







  <script defer src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.1.0/dist/lazyload.min.js"></script>
<script>
  // https://www.npmjs.com/package/vanilla-lazyload
  // Set the options globally
  // to make LazyLoad self-initialize
  window.lazyLoadOptions = {
    elements_selector: ".lazyload",
    threshold: 0
  };
  // Listen to the initialization event
  // and get the instance of LazyLoad
  window.addEventListener(
    "LazyLoad::Initialized",
    function (event) {
      window.lazyLoadInstance = event.detail.instance;
    },
    false
  );
  document.addEventListener('DOMContentLoaded', function () {
    lazyLoadInstance.update();
  });
  document.addEventListener('pjax:complete', function () {
    lazyLoadInstance.update();
  });
</script>




  
  
    <script>
      window.FPConfig = {
        delay: 0,
        ignoreKeywords: [],
        maxRPS: 5,
        hoverDelay: 25
      };
    </script>
    <script defer src="https://cdn.jsdelivr.net/gh/gijo-varghese/flying-pages@2.1.2/flying-pages.min.js"></script>
  




  <script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
    var clipboard = new ClipboardJS('.btn-copy', {
        target: function (trigger) {
            return trigger.nextElementSibling
        }
    });
    function wait(callback, seconds) {
        var timelag = null;
        timelag = window.setTimeout(callback, seconds)
    }
    function pjax_initCopyCode() {
		if($(".highlight .code pre").length+$(".article pre code").length==0)return;
        var copyHtml = '';
        copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
        copyHtml += '<i class="fas fa-copy"></i><span>COPY</span>';
        copyHtml += '</button>';
        $(".highlight .code pre").before(copyHtml);
        $(".article pre code").before(copyHtml);
        clipboard.off('success').on('success', function (e) {
            let $btn = $(e.trigger);
            $btn.addClass('copied');
            let $icon = $($btn.find('i'));
            $icon.removeClass('fa-copy');
            $icon.addClass('fa-check-circle');
            let $span = $($btn.find('span'));
            $span[0].innerText = 'COPIED';
            wait(function () {
                $icon.removeClass('fa-check-circle');
                $icon.addClass('fa-copy');
                $span[0].innerText = 'COPY'
            }, 2000)
        });
        clipboard.off('error').on('error', function (e) {
            e.clearSelection();
            let $btn = $(e.trigger);
            $btn.addClass('copy-failed');
            let $icon = $($btn.find('i'));
            $icon.removeClass('fa-copy');
            $icon.addClass('fa-times-circle');
            let $span = $($btn.find('span'));
            $span[0].innerText = 'COPY FAILED';
            wait(function () {
                $icon.removeClass('fa-times-circle');
                $icon.addClass('fa-copy');
                $span[0].innerText = 'COPY'
            }, 2000)
        })
    }
    $(function () {
        pjax_initCopyCode()
    });
</script>










  <script defer src="https://cdn.jsdelivr.net/gh/Schenk75/Source@master/tools/busuanzi.pure.mini.js" data-pjax></script>


  
<script src="https://cdn.jsdelivr.net/npm/hexo-theme-volantis@4.1.5/source/js/app.min.js"></script>




  
  
<script src="https://cdn.jsdelivr.net/npm/hexo-theme-volantis@4.1.5/source/js/search.min.js"></script>

  


<!-- optional -->

  <script>
const SearchServiceimagePath="https://cdn.jsdelivr.net/gh/volantis-x/cdn-volantis@master/img/";
const ROOT =  ("/" || "/").endsWith('/') ? ("/" || "/") : ("//" || "/" );
function listenSearch(){
  
    customSearch = new HexoSearch({
      imagePath: SearchServiceimagePath
    });
  
}
document.addEventListener("DOMContentLoaded", listenSearch);

</script>











  <script defer>

  const LCCounter = {
    app_id: 'u9j57bwJod4EDmXWdxrwuqQT-MdYXbMMI',
    app_key: 'jfHtEKVE24j0IVCGHbvuFClp',
    custom_api_server: '',

    // 查询存储的记录
    getRecord(Counter, url, title) {
      return new Promise(function (resolve, reject) {
        Counter('get', '/classes/Counter?where=' + encodeURIComponent(JSON.stringify({url})))
          .then(resp => resp.json())
          .then(({results, code, error}) => {
            if (code === 401) {
              throw error;
            }
            if (results && results.length > 0) {
              var record = results[0];
              resolve(record);
            } else {
              Counter('post', '/classes/Counter', {url, title: title, times: 0})
                .then(resp => resp.json())
                .then((record, error) => {
                  if (error) {
                    throw error;
                  }
                  resolve(record);
                }).catch(error => {
                console.error('Failed to create', error);
                reject(error);
              });
            }
          }).catch((error) => {
          console.error('LeanCloud Counter Error:', error);
          reject(error);
        });
      })
    },

    // 发起自增请求
    increment(Counter, incrArr) {
      return new Promise(function (resolve, reject) {
        Counter('post', '/batch', {
          "requests": incrArr
        }).then((res) => {
          res = res.json();
          if (res.error) {
            throw res.error;
          }
          resolve(res);
        }).catch((error) => {
          console.error('Failed to save visitor count', error);
          reject(error);
        });
      });
    },

    // 构建自增请求体
    buildIncrement(objectId) {
      return {
        "method": "PUT",
        "path": `/1.1/classes/Counter/${ objectId }`,
        "body": {
          "times": {
            '__op': 'Increment',
            'amount': 1
          }
        }
      }
    },

    // 校验是否为有效的 UV
    validUV() {
      var key = 'LeanCloudUVTimestamp';
      var flag = localStorage.getItem(key);
      if (flag) {
        // 距离标记小于 24 小时则不计为 UV
        if (new Date().getTime() - parseInt(flag) <= 86400000) {
          return false;
        }
      }
      localStorage.setItem(key, new Date().getTime().toString());
      return true;
    },

    addCount(Counter) {
      var enableIncr = '' === 'true' && window.location.hostname !== 'localhost';
      enableIncr = true;
      var getterArr = [];
      var incrArr = [];
      // 请求 PV 并自增
      var pvCtn = document.querySelector('#lc-sv');
      if (pvCtn || enableIncr) {
        var pvGetter = this.getRecord(Counter, 'http://example.com' + '/#lc-sv', 'Visits').then((record) => {
          incrArr.push(this.buildIncrement(record.objectId))
          var eles = document.querySelectorAll('#lc-sv #number');
          if (eles.length > 0) {
            eles.forEach((el,index,array)=>{
              el.innerText = record.times + 1;
              if (pvCtn) {
                pvCtn.style.display = 'inline';
              }
            })
          }
        });
        getterArr.push(pvGetter);
      }

      // 请求 UV 并自增
      var uvCtn = document.querySelector('#lc-uv');
      if (uvCtn || enableIncr) {
        var uvGetter = this.getRecord(Counter, 'http://example.com' + '/#lc-uv', 'Visitors').then((record) => {
          var vuv = this.validUV();
          vuv && incrArr.push(this.buildIncrement(record.objectId))
          var eles = document.querySelectorAll('#lc-uv #number');
          if (eles.length > 0) {
            eles.forEach((el,index,array)=>{
              el.innerText = record.times + (vuv ? 1 : 0);
              if (uvCtn) {
                uvCtn.style.display = 'inline';
              }
            })
          }
        });
        getterArr.push(uvGetter);
      }

      // 请求文章的浏览数，如果是当前页面就自增
      var allPV = document.querySelectorAll('#lc-pv');
      if (allPV.length > 0 || enableIncr) {
        for (i = 0; i < allPV.length; i++) {
          let pv = allPV[i];
          let title = pv.getAttribute('data-title');
          var url = 'http://example.com' + pv.getAttribute('data-path');
          if (url) {
            var viewGetter = this.getRecord(Counter, url, title).then((record) => {
              // 是当前页面就自增
              let curPath = window.location.pathname;
              if (curPath.includes('index.html')) {
                curPath = curPath.substring(0, curPath.lastIndexOf('index.html'));
              }
              if (pv.getAttribute('data-path') == curPath) {
                incrArr.push(this.buildIncrement(record.objectId));
              }
              if (pv) {
                var ele = pv.querySelector('#lc-pv #number');
                if (ele) {
                  if (pv.getAttribute('data-path') == curPath) {
                    ele.innerText = (record.times || 0) + 1;
                  } else {
                    ele.innerText = record.times || 0;
                  }
                  pv.style.display = 'inline';
                }
              }
            });
            getterArr.push(viewGetter);
          }
        }
      }

      // 如果启动计数自增，批量发起自增请求
      if (enableIncr) {
        Promise.all(getterArr).then(() => {
          incrArr.length > 0 && this.increment(Counter, incrArr);
        })
      }

    },


    fetchData(api_server) {
      var Counter = (method, url, data) => {
        return fetch(`${ api_server }/1.1${ url }`, {
          method,
          headers: {
            'X-LC-Id': this.app_id,
            'X-LC-Key': this.app_key,
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(data)
        });
      };
      this.addCount(Counter);
    },

    refreshCounter() {
      var api_server = this.app_id.slice(-9) !== '-MdYXbMMI' ? this.custom_api_server : `https://${ this.app_id.slice(0, 8).toLowerCase() }.api.lncldglobal.com`;
      if (api_server) {
        this.fetchData(api_server);
      } else {
        fetch('https://app-router.leancloud.cn/2/route?appId=' + this.app_id)
          .then(resp => resp.json())
          .then(({api_server}) => {
            this.fetchData('https://' + api_server);
          });
      }
    }

  };

  LCCounter.refreshCounter();

  document.addEventListener('pjax:complete', function () {
    LCCounter.refreshCounter();
  });
</script>








<script>
function listennSidebarTOC() {
  const navItems = document.querySelectorAll(".toc li");
  if (!navItems.length) return;
  const sections = [...navItems].map((element) => {
    const link = element.querySelector(".toc-link");
    const target = document.getElementById(
      decodeURI(link.getAttribute("href")).replace("#", "")
    );
    link.addEventListener("click", (event) => {
      event.preventDefault();
      window.scrollTo({
		top: target.offsetTop + 100,
		
		behavior: "smooth"
		
	  });
    });
    return target;
  });

  function activateNavByIndex(target) {
    if (target.classList.contains("active-current")) return;

    document.querySelectorAll(".toc .active").forEach((element) => {
      element.classList.remove("active", "active-current");
    });
    target.classList.add("active", "active-current");
    let parent = target.parentNode;
    while (!parent.matches(".toc")) {
      if (parent.matches("li")) parent.classList.add("active");
      parent = parent.parentNode;
    }
  }

  function findIndex(entries) {
    let index = 0;
    let entry = entries[index];
    if (entry.boundingClientRect.top > 0) {
      index = sections.indexOf(entry.target);
      return index === 0 ? 0 : index - 1;
    }
    for (; index < entries.length; index++) {
      if (entries[index].boundingClientRect.top <= 0) {
        entry = entries[index];
      } else {
        return sections.indexOf(entry.target);
      }
    }
    return sections.indexOf(entry.target);
  }

  function createIntersectionObserver(marginTop) {
    marginTop = Math.floor(marginTop + 10000);
    let intersectionObserver = new IntersectionObserver(
      (entries, observe) => {
        let scrollHeight = document.documentElement.scrollHeight + 100;
        if (scrollHeight > marginTop) {
          observe.disconnect();
          createIntersectionObserver(scrollHeight);
          return;
        }
        let index = findIndex(entries);
        activateNavByIndex(navItems[index]);
      },
      {
        rootMargin: marginTop + "px 0px -100% 0px",
        threshold: 0,
      }
    );
    sections.forEach((element) => {
      element && intersectionObserver.observe(element);
    });
  }
  createIntersectionObserver(document.documentElement.scrollHeight);
}

document.addEventListener("DOMContentLoaded", listennSidebarTOC);
document.addEventListener("pjax:success", listennSidebarTOC);
</script>

<!-- more -->




    
      


<script src="https://cdn.jsdelivr.net/npm/pjax@0.2.8/pjax.min.js"></script>


<script>
    var pjax;
    document.addEventListener('DOMContentLoaded', function () {
      pjax = new Pjax({
        elements: 'a[href]:not([href^="#"]):not([href="javascript:void(0)"]):not([pjax-fancybox])',
        selectors: [
          "title",
          "#l_cover",
          "#pjax-container",
          "#pjax-header-nav-list"
        ],
        cacheBust: false,   // url 地址追加时间戳，用以避免浏览器缓存
        timeout: 5000
      });
    });

    document.addEventListener('pjax:send', function (e) {
      //window.stop(); // 相当于点击了浏览器的停止按钮

      try {
        var currentUrl = window.location.pathname;
        var targetUrl = e.triggerElement.href;
        var banUrl = [""];
        if (banUrl[0] != "") {
          banUrl.forEach(item => {
            if(currentUrl.indexOf(item) != -1 || targetUrl.indexOf(item) != -1) {
              window.location.href = targetUrl;
            }
          });
        }
      } catch (error) {}

      window.subData = null; // 移除标题（用于一二级导航栏切换处）
      if (typeof $.fancybox != "undefined") {
        $.fancybox.close();    // 关闭弹窗
      }
      volantis.$switcher.removeClass('active'); // 关闭移动端激活的搜索框
      volantis.$header.removeClass('z_search-open'); // 关闭移动端激活的搜索框
      volantis.$wrapper.removeClass('sub'); // 跳转页面时关闭二级导航

      // 解绑事件 避免重复监听
      volantis.$topBtn.unbind('click');
      $('.menu a').unbind('click');
      $(window).unbind('resize');
      $(window).unbind('scroll');
      $(document).unbind('scroll');
      $(document).unbind('click');
      $('body').unbind('click');
	  
    });

    document.addEventListener('pjax:complete', function () {
      // 关于百度统计对 SPA 页面的处理：
      // 方案一：百度统计>管理>单页应用设置中，打开开启按钮即可对SPA进行统计。 https://tongji.baidu.com/web/help/article?id=324
      // 方案二：取消注释下列代码。 https://tongji.baidu.com/web/help/article?id=235
      // 

      // 关于谷歌统计对 SPA 页面的处理：
      // 当应用以动态方式加载内容并更新地址栏中的网址时，也应该更新通过 gtag.js 存储的网页网址。
      // https://developers.google.cn/analytics/devguides/collection/gtagjs/single-page-applications?hl=zh-cn
      

      $('.nav-main').find('.list-v').not('.menu-phone').removeAttr("style",""); // 移除小尾巴的移除
      $('.menu-phone.list-v').removeAttr("style",""); // 移除小尾巴的移除
      $('script[data-pjax], .pjax-reload script').each(function () {
        $(this).parent().append($(this).remove());
      });
      try{
          if (typeof $.fancybox == "undefined") {
            SCload_fancybox();
          } else {
            pjax_fancybox();
          }
        
        
        
        
        
          pjax_initCopyCode();
        
        
        
        
        
      } catch (e) {
        console.log(e);
      }
	  
    });

    document.addEventListener('pjax:error', function (e) {
	  
      window.location.href = e.triggerElement.href;
    });
</script>

    
  </div>
</body>
</html>
